(function(window, document, $, undefined){ "use strict"; window.console=window.console||{ info: function(stuff){}}; if(!$){ return; } if($.fn.fancybox){ console.info("fancyBox already initialized"); return; } var defaults={ loop: false, gutter: 50, keyboard: true, arrows: true, infobar: true, smallBtn: "auto", toolbar: "auto", buttons: [ "zoom", "thumbs", "close" ], idleTime: 3, protect: false, modal: false, image: { preload: false }, ajax: { settings: { data: { fancybox: true }} }, iframe: { tpl: '', preload: true, css: {}, attr: { scrolling: "auto" }}, defaultType: "image", animationEffect: "zoom", animationDuration: 366, zoomOpacity: "auto", transitionEffect: "fade", transitionDuration: 366, slideClass: "", baseClass: "", baseTpl: '", spinnerTpl: '
', errorTpl: '

{{ERROR}}

', btnTpl: { download: '' + '' + '' + "" + "", zoom: '", close: '", smallBtn: '', arrowLeft: '' + '' + '' + "" + "", arrowRight: '' + '' + '' + "" + "" }, parentEl: "body", autoFocus: false, backFocus: true, trapFocus: true, fullScreen: { autoStart: false }, touch: { vertical: true, momentum: true }, hash: null, media: {}, slideShow: { autoStart: false, speed: 4000 }, thumbs: { autoStart: false, hideOnClose: true, parentEl: ".fancybox-container", axis: "y" }, wheel: "auto", /* afterShow: function(instance, current){ console.info('Clicked element:'); console.info(current.opts.$orig); } */ onInit: $.noop, beforeLoad: $.noop, afterLoad: $.noop, beforeShow: $.noop, afterShow: $.noop, beforeClose: $.noop, afterClose: $.noop, onActivate: $.noop, onDeactivate: $.noop, clickContent: function(current, event){ return current.type==="image" ? "zoom":false; }, clickSlide: "close", clickOutside: "close", dblclickContent: false, dblclickSlide: false, dblclickOutside: false, mobile: { idleTime: false, clickContent: function(current, event){ return current.type==="image" ? "toggleControls":false; }, clickSlide: function(current, event){ return current.type==="image" ? "toggleControls":"close"; }, dblclickContent: function(current, event){ return current.type==="image" ? "zoom":false; }, dblclickSlide: function(current, event){ return current.type==="image" ? "zoom":false; }}, lang: "en", i18n: { en: { CLOSE: "Close", NEXT: "Next", PREV: "Previous", ERROR: "The requested content cannot be loaded.
Please try again later.", PLAY_START: "Start slideshow", PLAY_STOP: "Pause slideshow", FULL_SCREEN: "Full screen", THUMBS: "Thumbnails", DOWNLOAD: "Download", SHARE: "Share", ZOOM: "Zoom" }, de: { CLOSE: "Schliessen", NEXT: "Weiter", PREV: "Zurück", ERROR: "Die angeforderten Daten konnten nicht geladen werden.
Bitte versuchen Sie es später nochmal.", PLAY_START: "Diaschau starten", PLAY_STOP: "Diaschau beenden", FULL_SCREEN: "Vollbild", THUMBS: "Vorschaubilder", DOWNLOAD: "Herunterladen", SHARE: "Teilen", ZOOM: "Maßstab" }} }; var $W=$(window); var $D=$(document); var called=0; var isQuery=function(obj){ return obj&&obj.hasOwnProperty&&obj instanceof $; }; var requestAFrame=(function(){ return ( window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || function(callback){ return window.setTimeout(callback, 1000 / 60); } ); })(); var transitionEnd=(function(){ var el=document.createElement("fakeelement"), t; var transitions={ transition: "transitionend", OTransition: "oTransitionEnd", MozTransition: "transitionend", WebkitTransition: "webkitTransitionEnd" }; for (t in transitions){ if(el.style[t]!==undefined){ return transitions[t]; }} return "transitionend"; })(); var forceRedraw=function($el){ return $el&&$el.length&&$el[0].offsetHeight; }; var mergeOpts=function(opts1, opts2){ var rez=$.extend(true, {}, opts1, opts2); $.each(opts2, function(key, value){ if($.isArray(value)){ rez[key]=value; }}); return rez; }; var FancyBox=function(content, opts, index){ var self=this; self.opts=mergeOpts({index: index}, $.fancybox.defaults); if($.isPlainObject(opts)){ self.opts=mergeOpts(self.opts, opts); } if($.fancybox.isMobile){ self.opts=mergeOpts(self.opts, self.opts.mobile); } self.id=self.opts.id||++called; self.currIndex=parseInt(self.opts.index, 10)||0; self.prevIndex=null; self.prevPos=null; self.currPos=0; self.firstRun=true; self.group=[]; self.slides={}; self.addContent(content); if(!self.group.length){ return; } self.$lastFocus=$(document.activeElement).trigger("blur"); self.init(); }; $.extend(FancyBox.prototype, { init: function(){ var self=this, firstItem=self.group[self.currIndex], firstItemOpts=firstItem.opts, scrollbarWidth=$.fancybox.scrollbarWidth, $scrollDiv, $container, buttonStr; if(!$.fancybox.getInstance()&&firstItemOpts.hideScrollbar!==false){ $("body").addClass("fancybox-active"); if(!$.fancybox.isMobile&&document.body.scrollHeight > window.innerHeight){ if(scrollbarWidth===undefined){ $scrollDiv=$('
').appendTo("body"); scrollbarWidth=$.fancybox.scrollbarWidth=$scrollDiv[0].offsetWidth - $scrollDiv[0].clientWidth; $scrollDiv.remove(); } $("head").append('" ); $("body").addClass("compensate-for-scrollbar"); }} buttonStr=""; $.each(firstItemOpts.buttons, function(index, value){ buttonStr +=firstItemOpts.btnTpl[value]||""; }); $container=$( self.translate(self, firstItemOpts.baseTpl .replace("{{buttons}}", buttonStr) .replace("{{arrows}}", firstItemOpts.btnTpl.arrowLeft + firstItemOpts.btnTpl.arrowRight) ) ) .attr("id", "fancybox-container-" + self.id) .addClass("fancybox-is-hidden") .addClass(firstItemOpts.baseClass) .data("FancyBox", self) .appendTo(firstItemOpts.parentEl); self.$refs={ container: $container }; ["bg", "inner", "infobar", "toolbar", "stage", "caption", "navigation"].forEach(function(item){ self.$refs[item]=$container.find(".fancybox-" + item); }); self.trigger("onInit"); self.activate(); self.jumpTo(self.currIndex); }, translate: function(obj, str){ var arr=obj.opts.i18n[obj.opts.lang]; return str.replace(/\{\{(\w+)\}\}/g, function(match, n){ var value=arr[n]; if(value===undefined){ return match; } return value; }); }, addContent: function(content){ var self=this, items=$.makeArray(content), thumbs; $.each(items, function(i, item){ var obj={}, opts={}, $item, type, found, src, srcParts; if($.isPlainObject(item)){ obj=item; opts=item.opts||item; }else if($.type(item)==="object"&&$(item).length){ $item=$(item); opts=$item.data()||{}; opts=$.extend(true, {}, opts, opts.options); opts.$orig=$item; obj.src=self.opts.src||opts.src||$item.attr("href"); if(!obj.type&&!obj.src){ obj.type="inline"; obj.src=item; }}else{ obj={ type: "html", src: item + "" };} obj.opts=$.extend(true, {}, self.opts, opts); if($.isArray(opts.buttons)){ obj.opts.buttons=opts.buttons; } type=obj.type||obj.opts.type; src=obj.src||""; if(!type&&src){ if((found=src.match(/\.(mp4|mov|ogv)((\?|#).*)?$/i))){ type="video"; if(!obj.opts.videoFormat){ obj.opts.videoFormat="video/" + (found[1]==="ogv" ? "ogg":found[1]); }}else if(src.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i)){ type="image"; }else if(src.match(/\.(pdf)((\?|#).*)?$/i)){ type="iframe"; }else if(src.charAt(0)==="#"){ type="inline"; }} if(type){ obj.type=type; }else{ self.trigger("objectNeedsType", obj); } if(!obj.contentType){ obj.contentType=$.inArray(obj.type, ["html", "inline", "ajax"]) > -1 ? "html":obj.type; } obj.index=self.group.length; if(obj.opts.smallBtn=="auto"){ obj.opts.smallBtn=$.inArray(obj.type, ["html", "inline", "ajax"]) > -1; } if(obj.opts.toolbar==="auto"){ obj.opts.toolbar = !obj.opts.smallBtn; } if(obj.opts.$trigger&&obj.index===self.opts.index){ obj.opts.$thumb=obj.opts.$trigger.find("img:first"); } if((!obj.opts.$thumb||!obj.opts.$thumb.length)&&obj.opts.$orig){ obj.opts.$thumb=obj.opts.$orig.find("img:first"); } if($.type(obj.opts.caption)==="function"){ obj.opts.caption=obj.opts.caption.apply(item, [self, obj]); } if($.type(self.opts.caption)==="function"){ obj.opts.caption=self.opts.caption.apply(item, [self, obj]); } if(!(obj.opts.caption instanceof $)){ obj.opts.caption=obj.opts.caption===undefined ? "":obj.opts.caption + ""; } if(obj.type==="ajax"){ srcParts=src.split(/\s+/, 2); if(srcParts.length > 1){ obj.src=srcParts.shift(); obj.opts.filter=srcParts.shift(); }} if(obj.opts.modal){ obj.opts=$.extend(true, obj.opts, { infobar: 0, toolbar: 0, smallBtn: 0, keyboard: 0, slideShow: 0, fullScreen: 0, thumbs: 0, touch: 0, clickContent: false, clickSlide: false, clickOutside: false, dblclickContent: false, dblclickSlide: false, dblclickOutside: false }); } self.group.push(obj); }); if(Object.keys(self.slides).length){ self.updateControls(); thumbs=self.Thumbs; if(thumbs&&thumbs.isActive){ thumbs.create(); thumbs.focus(); }} }, addEvents: function(){ var self=this; self.removeEvents(); self.$refs.container .on("click.fb-close", "[data-fancybox-close]", function(e){ e.stopPropagation(); e.preventDefault(); self.close(e); }) .on("touchstart.fb-prev click.fb-prev", "[data-fancybox-prev]", function(e){ e.stopPropagation(); e.preventDefault(); self.previous(); }) .on("touchstart.fb-next click.fb-next", "[data-fancybox-next]", function(e){ e.stopPropagation(); e.preventDefault(); self.next(); }) .on("click.fb", "[data-fancybox-zoom]", function(e){ self[self.isScaledDown() ? "scaleToActual":"scaleToFit"](); }); $W.on("orientationchange.fb resize.fb", function(e){ if(e&&e.originalEvent&&e.originalEvent.type==="resize"){ requestAFrame(function(){ self.update(); }); }else{ self.$refs.stage.hide(); setTimeout(function(){ self.$refs.stage.show(); self.update(); }, $.fancybox.isMobile ? 600:250); }}); $D.on("focusin.fb", function(e){ var instance=$.fancybox ? $.fancybox.getInstance():null; if(instance.isClosing || !instance.current || !instance.current.opts.trapFocus || $(e.target).hasClass("fancybox-container") || $(e.target).is(document) ){ return; } if(instance&&$(e.target).css("position")!=="fixed"&&!instance.$refs.container.has(e.target).length){ e.stopPropagation(); instance.focus(); }}); $D.on("keydown.fb", function(e){ var current=self.current, keycode=e.keyCode||e.which; if(!current||!current.opts.keyboard){ return; } if(e.ctrlKey||e.altKey||e.shiftKey||$(e.target).is("input")||$(e.target).is("textarea")){ return; } if(keycode===8||keycode===27){ e.preventDefault(); self.close(e); return; } if(keycode===37||keycode===38){ e.preventDefault(); self.previous(); return; } if(keycode===39||keycode===40){ e.preventDefault(); self.next(); return; } self.trigger("afterKeydown", e, keycode); }); if(self.group[self.currIndex].opts.idleTime){ self.idleSecondsCounter=0; $D.on("mousemove.fb-idle mouseleave.fb-idle mousedown.fb-idle touchstart.fb-idle touchmove.fb-idle scroll.fb-idle keydown.fb-idle", function(e){ self.idleSecondsCounter=0; if(self.isIdle){ self.showControls(); } self.isIdle=false; } ); self.idleInterval=window.setInterval(function(){ self.idleSecondsCounter++; if(self.idleSecondsCounter >=self.group[self.currIndex].opts.idleTime&&!self.isDragging){ self.isIdle=true; self.idleSecondsCounter=0; self.hideControls(); }}, 1000); }}, removeEvents: function(){ var self=this; $W.off("orientationchange.fb resize.fb"); $D.off("focusin.fb keydown.fb .fb-idle"); this.$refs.container.off(".fb-close .fb-prev .fb-next"); if(self.idleInterval){ window.clearInterval(self.idleInterval); self.idleInterval=null; }}, previous: function(duration){ return this.jumpTo(this.currPos - 1, duration); }, next: function(duration){ return this.jumpTo(this.currPos + 1, duration); }, jumpTo: function(pos, duration){ var self=this, groupLen=self.group.length, firstRun, loop, current, previous, canvasWidth, currentPos, transitionProps; if(self.isDragging||self.isClosing||(self.isAnimating&&self.firstRun)){ return; } pos=parseInt(pos, 10); loop=self.current ? self.current.opts.loop:self.opts.loop; if(!loop&&(pos < 0||pos >=groupLen)){ return false; } firstRun=self.firstRun = !Object.keys(self.slides).length; if(groupLen < 2&&!firstRun&&!!self.isDragging){ return; } previous=self.current; self.prevIndex=self.currIndex; self.prevPos=self.currPos; current=self.createSlide(pos); if(groupLen > 1){ if(loop||current.index > 0){ self.createSlide(pos - 1); } if(loop||current.index < groupLen - 1){ self.createSlide(pos + 1); }} self.current=current; self.currIndex=current.index; self.currPos=current.pos; self.trigger("beforeShow", firstRun); self.updateControls(); currentPos=$.fancybox.getTranslate(current.$slide); current.isMoved=(currentPos.left!==0||currentPos.top!==0)&&!current.$slide.hasClass("fancybox-animated"); current.forcedDuration=undefined; if($.isNumeric(duration)){ current.forcedDuration=duration; }else{ duration=current.opts[firstRun ? "animationDuration":"transitionDuration"]; } duration=parseInt(duration, 10); if(firstRun){ if(current.opts.animationEffect&&duration){ self.$refs.container.css("transition-duration", duration + "ms"); } self.$refs.container.removeClass("fancybox-is-hidden"); forceRedraw(self.$refs.container); self.$refs.container.addClass("fancybox-is-open"); forceRedraw(self.$refs.container); current.$slide.addClass("fancybox-slide--previous"); self.loadSlide(current); current.$slide.removeClass("fancybox-slide--previous").addClass("fancybox-slide--current"); self.preload("image"); return; } $.each(self.slides, function(index, slide){ $.fancybox.stop(slide.$slide); }); current.$slide.removeClass("fancybox-slide--next fancybox-slide--previous").addClass("fancybox-slide--current"); if(current.isMoved){ canvasWidth=Math.round(current.$slide.width()); $.each(self.slides, function(index, slide){ var pos=slide.pos - current.pos; $.fancybox.animate(slide.$slide, { top: 0, left: pos * canvasWidth + pos * slide.opts.gutter }, duration, function(){ slide.$slide.removeAttr("style").removeClass("fancybox-slide--next fancybox-slide--previous"); if(slide.pos===self.currPos){ current.isMoved=false; self.complete(); }} ); }); }else{ self.$refs.stage.children().removeAttr("style"); } if(current.isLoaded){ self.revealContent(current); }else{ self.loadSlide(current); } self.preload("image"); if(previous.pos===current.pos){ return; } transitionProps="fancybox-slide--" + (previous.pos > current.pos ? "next":"previous"); previous.$slide.removeClass("fancybox-slide--complete fancybox-slide--current fancybox-slide--next fancybox-slide--previous"); previous.isComplete=false; if(!duration||(!current.isMoved&&!current.opts.transitionEffect)){ return; } if(current.isMoved){ previous.$slide.addClass(transitionProps); }else{ transitionProps="fancybox-animated " + transitionProps + " fancybox-fx-" + current.opts.transitionEffect; $.fancybox.animate(previous.$slide, transitionProps, duration, function(){ previous.$slide.removeClass(transitionProps).removeAttr("style"); }); }}, createSlide: function(pos){ var self=this, $slide, index; index=pos % self.group.length; index=index < 0 ? self.group.length + index:index; if(!self.slides[pos]&&self.group[index]){ $slide=$('
').appendTo(self.$refs.stage); self.slides[pos]=$.extend(true, {}, self.group[index], { pos: pos, $slide: $slide, isLoaded: false }); self.updateSlide(self.slides[pos]); } return self.slides[pos]; }, scaleToActual: function(x, y, duration){ var self=this, current=self.current, $content=current.$content, canvasWidth=$.fancybox.getTranslate(current.$slide).width, canvasHeight=$.fancybox.getTranslate(current.$slide).height, newImgWidth=current.width, newImgHeight=current.height, imgPos, posX, posY, scaleX, scaleY; if(self.isAnimating||!$content||!(current.type=="image"&¤t.isLoaded&&!current.hasError)){ return; } $.fancybox.stop($content); self.isAnimating=true; x=x===undefined ? canvasWidth * 0.5:x; y=y===undefined ? canvasHeight * 0.5:y; imgPos=$.fancybox.getTranslate($content); imgPos.top -=$.fancybox.getTranslate(current.$slide).top; imgPos.left -=$.fancybox.getTranslate(current.$slide).left; scaleX=newImgWidth / imgPos.width; scaleY=newImgHeight / imgPos.height; posX=canvasWidth * 0.5 - newImgWidth * 0.5; posY=canvasHeight * 0.5 - newImgHeight * 0.5; if(newImgWidth > canvasWidth){ posX=imgPos.left * scaleX - (x * scaleX - x); if(posX > 0){ posX=0; } if(posX < canvasWidth - newImgWidth){ posX=canvasWidth - newImgWidth; }} if(newImgHeight > canvasHeight){ posY=imgPos.top * scaleY - (y * scaleY - y); if(posY > 0){ posY=0; } if(posY < canvasHeight - newImgHeight){ posY=canvasHeight - newImgHeight; }} self.updateCursor(newImgWidth, newImgHeight); $.fancybox.animate($content, { top: posY, left: posX, scaleX: scaleX, scaleY: scaleY }, duration||330, function(){ self.isAnimating=false; } ); if(self.SlideShow&&self.SlideShow.isActive){ self.SlideShow.stop(); }}, scaleToFit: function(duration){ var self=this, current=self.current, $content=current.$content, end; if(self.isAnimating||!$content||!(current.type=="image"&¤t.isLoaded&&!current.hasError)){ return; } $.fancybox.stop($content); self.isAnimating=true; end=self.getFitPos(current); self.updateCursor(end.width, end.height); $.fancybox.animate($content, { top: end.top, left: end.left, scaleX: end.width / $content.width(), scaleY: end.height / $content.height() }, duration||330, function(){ self.isAnimating=false; } ); }, getFitPos: function(slide){ var self=this, $content=slide.$content, width=slide.width||slide.opts.width, height=slide.height||slide.opts.height, maxWidth, maxHeight, minRatio, margin, aspectRatio, rez={}; if(!slide.isLoaded||!$content||!$content.length){ return false; } margin={ top: parseInt(slide.$slide.css("paddingTop"), 10), right: parseInt(slide.$slide.css("paddingRight"), 10), bottom: parseInt(slide.$slide.css("paddingBottom"), 10), left: parseInt(slide.$slide.css("paddingLeft"), 10) }; maxWidth=parseInt(self.$refs.stage.width(), 10) - (margin.left + margin.right); maxHeight=parseInt(self.$refs.stage.height(), 10) - (margin.top + margin.bottom); if(!width||!height){ width=maxWidth; height=maxHeight; } minRatio=Math.min(1, maxWidth / width, maxHeight / height); width=Math.floor(minRatio * width); height=Math.floor(minRatio * height); if(slide.type==="image"){ rez.top=Math.floor((maxHeight - height) * 0.5) + margin.top; rez.left=Math.floor((maxWidth - width) * 0.5) + margin.left; }else if(slide.contentType==="video"){ aspectRatio=slide.opts.width&&slide.opts.height ? width / height:slide.opts.ratio||16 / 9; if(height > width / aspectRatio){ height=width / aspectRatio; }else if(width > height * aspectRatio){ width=height * aspectRatio; }} rez.width=width; rez.height=height; return rez; }, update: function(){ var self=this; $.each(self.slides, function(key, slide){ self.updateSlide(slide); }); }, updateSlide: function(slide, duration){ var self=this, $content=slide&&slide.$content, width=slide.width||slide.opts.width, height=slide.height||slide.opts.height; if($content&&(width||height||slide.contentType==="video")&&!slide.hasError){ $.fancybox.stop($content); $.fancybox.setTranslate($content, self.getFitPos(slide)); if(slide.pos===self.currPos){ self.isAnimating=false; self.updateCursor(); }} slide.$slide.trigger("refresh"); self.$refs.toolbar.toggleClass("compensate-for-scrollbar", slide.$slide.get(0).scrollHeight > slide.$slide.get(0).clientHeight); self.trigger("onUpdate", slide); }, centerSlide: function(slide, duration){ var self=this, canvasWidth, pos; if(self.current){ canvasWidth=Math.round(slide.$slide.width()); pos=slide.pos - self.current.pos; $.fancybox.animate(slide.$slide, { top: 0, left: pos * canvasWidth + pos * slide.opts.gutter, opacity: 1 }, duration===undefined ? 0:duration, null, false ); }}, updateCursor: function(nextWidth, nextHeight){ var self=this, current=self.current, $container=self.$refs.container.removeClass("fancybox-is-zoomable fancybox-can-zoomIn fancybox-can-drag fancybox-can-zoomOut"), isZoomable; if(!current||self.isClosing){ return; } isZoomable=self.isZoomable(); $container.toggleClass("fancybox-is-zoomable", isZoomable); $("[data-fancybox-zoom]").prop("disabled", !isZoomable); if(isZoomable && (current.opts.clickContent==="zoom"||($.isFunction(current.opts.clickContent)&¤t.opts.clickContent(current)==="zoom")) ){ if(self.isScaledDown(nextWidth, nextHeight)){ $container.addClass("fancybox-can-zoomIn"); }else{ if(current.opts.touch){ $container.addClass("fancybox-can-drag"); }else{ $container.addClass("fancybox-can-zoomOut"); }} }else if(current.opts.touch&¤t.contentType!=="video"){ $container.addClass("fancybox-can-drag"); }}, isZoomable: function(){ var self=this, current=self.current, fitPos; if(current&&!self.isClosing&¤t.type==="image"&&!current.hasError){ if(!current.isLoaded){ return true; } fitPos=self.getFitPos(current); if(current.width > fitPos.width||current.height > fitPos.height){ return true; }} return false; }, isScaledDown: function(nextWidth, nextHeight){ var self=this, rez=false, current=self.current, $content=current.$content; if(nextWidth!==undefined&&nextHeight!==undefined){ rez=nextWidth < current.width&&nextHeight < current.height; }else if($content){ rez=$.fancybox.getTranslate($content); rez=rez.width < current.width&&rez.height < current.height; } return rez; }, canPan: function(){ var self=this, rez=false, current=self.current, $content; if(current.type==="image"&&($content=current.$content)&&!current.hasError){ rez=self.getFitPos(current); rez=Math.abs($content.width() - rez.width) > 1||Math.abs($content.height() - rez.height) > 1; } return rez; }, loadSlide: function(slide){ var self=this, type, $slide, ajaxLoad; if(slide.isLoading||slide.isLoaded){ return; } slide.isLoading=true; self.trigger("beforeLoad", slide); type=slide.type; $slide=slide.$slide; $slide .off("refresh") .trigger("onReset") .addClass(slide.opts.slideClass); switch (type){ case "image": self.setImage(slide); break; case "iframe": self.setIframe(slide); break; case "html": self.setContent(slide, slide.src||slide.content); break; case "video": self.setContent(slide, '